﻿@model IEnumerable<FindTheBest.Models.Category>

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
    var arr = new List<string>();
    var k = 1;
}

<!--<div class="home_cat_boxes clearfix">-->
@foreach (var item in Model)
{
    if (item.ParentId == 0)
    {
        var str = "<div class='cat_box_header bg_grad' onclick='javascript: window.location = http://www.findthebest.com/category/Business-And-Finance&#39;;'>" +
                  "<div class='icon' Bus'></div>" +
                  "<div class='title'><a href='http://www.findthebest.com/category/Business-And-Finance'>" +
                  item.Name +
                  "</a></div></div><div class='cat_box_body clearfix'>";

        str = Model.Where(item2nd => item2nd.ParentId == item.ID).Take(5).Aggregate(str, (current, item2nd) => current + ("<span class='cat_wrapper'><a class='' href='http://financial-advisors.findthebest.com/'><span class='bullet'></span> " + item2nd.Name + "</a></span>"));

        str += "<span class='cat_wrapper'><a class='show-all' href='http://www.findthebest.com/category/Business-And-Finance' rel='nofollow'><span class='bullet'></span>Show All</a></span></div>";
        if (k%2 == 0)
        {
            str = "<div class='cat_box'>" + str + "</div>";
        }
        else
        {
            str = "<div class='cat_box right'>" + str + "</div>";
        }
        arr.Add(str);
        k++;
    }
}

@Html.Raw("<div class='home_cat_boxes clearfix'>")

    @for (int i = 0; i < arr.Count; i++)
    { 
        @Html.Raw(arr[i])
        if ((i+1)%2 == 0)
        {
            @Html.Raw("</div><div class='home_cat_boxes clearfix'>");
        }
    }

@Html.Raw("</div>");
